mod_rewrite [L] flag not working as expected?

Posted by bobobobo on Server Fault See other posts from Server Fault or by bobobobo
Published on 2010-12-23T23:46:04Z Indexed on 2010/12/23 23:55 UTC
Read the original article Hit count: 139

Filed under:
|
|

I thought the [L] flag indicated that "this rule should be the last rule processed for this http request.."

However when I have 2 rules like:

RewriteRule ^test$ php/test.php [L]
RewriteRule (.*) error.php

What always happens is requests to http://localhost/test go to error.php, not to test.php as I expected, since I put the [L] there. If you comment out the second rule there, then requests to http://localhost/test go to test.php as expected.

What I'm really trying to do is catch 404 errors with mod_rewrite. Its possible what I'm trying to do is just plain wrong. But I still want to know why the catch-all rule is active since I did put an [L] after the ^test rule.

I see a large listing in here where the server admin lists a bunch of paths that begin with the recognized directories, but I wanted to avoid doing this by simply using a nice catch-all rule.

© Server Fault or respective owner

Related posts about apache

Related posts about mod-rewrite